package view.bookAdmiView;

import java.awt.BorderLayout;
import java.awt.EventQueue;

import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;

import view.logOnView.LogOnFrm1;

import javax.swing.GroupLayout;
import javax.swing.GroupLayout.Alignment;
import javax.swing.JMenuBar;
import javax.swing.JMenu;
import javax.swing.JMenuItem;
import javax.swing.JOptionPane;
import javax.swing.JDesktopPane;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import java.awt.Font;
import javax.swing.ImageIcon;
import java.awt.Color;
import java.awt.Insets;
import java.awt.Toolkit;

public class BookAdmiMainFrm extends JFrame {

	private JPanel contentPane;
	private JDesktopPane table=new JDesktopPane();

	/**
	 * Launch the application.
	 */
	public static void main(String[] args) {
		EventQueue.invokeLater(new Runnable() {
			public void run() {
				try {
					BookAdmiMainFrm frame = new BookAdmiMainFrm();
					frame.setVisible(true);
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		});
	}

	/**
	 * Create the frame.
	 */
	public BookAdmiMainFrm() {
		setIconImage(Toolkit.getDefaultToolkit().getImage(BookAdmiMainFrm.class.getResource("/images/bookAdmi/图书管理员.png")));
		setFont(new Font("微软雅黑", Font.BOLD, 33));
		setTitle("图书管理员主界面");
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		setBounds(100, 100, 671, 619);
		
		JMenuBar menuBar = new JMenuBar();
		menuBar.setBackground(new Color(245, 245, 220));
		menuBar.setForeground(Color.BLACK);
		setJMenuBar(menuBar);
		
		JMenu bookMaintainMenu = new JMenu(" 图书基本数据维护              ");
		bookMaintainMenu.setForeground(Color.BLACK);
		bookMaintainMenu.setBackground(Color.BLACK);
		bookMaintainMenu.setIcon(new ImageIcon(BookAdmiMainFrm.class.getResource("/images/bookAdmi/数据维护.png")));
		bookMaintainMenu.setFont(new Font("Microsoft YaHei UI", Font.BOLD, 25));
		menuBar.add(bookMaintainMenu);
		
		JMenu bookTypemanageMenu = new JMenu("图书类别管理");
		bookTypemanageMenu.setIcon(new ImageIcon(BookAdmiMainFrm.class.getResource("/images/bookAdmi/图书类别管理.png")));
		bookTypemanageMenu.setFont(new Font("Microsoft YaHei UI", Font.BOLD, 28));
		bookMaintainMenu.add(bookTypemanageMenu);
		
		JMenuItem bookTypeAddMenuItem = new JMenuItem("图书类别添加");
		bookTypeAddMenuItem.setIcon(new ImageIcon(BookAdmiMainFrm.class.getResource("/images/bookAdmi/添加 (1).png")));
		bookTypeAddMenuItem.setFont(new Font("Microsoft YaHei UI", Font.BOLD, 25));
		bookTypeAddMenuItem.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				BookTypeAddInterFrm bookTypeAddInterFrm=new BookTypeAddInterFrm();
				bookTypeAddInterFrm.setVisible(true);
				table.add(bookTypeAddInterFrm);
				
			}
		});
		bookTypemanageMenu.add(bookTypeAddMenuItem);
		
		JMenuItem bookTypePMtMenuItem = new JMenuItem("图书类别维护");
		bookTypePMtMenuItem.setIcon(new ImageIcon(BookAdmiMainFrm.class.getResource("/images/bookAdmi/图书类别维护.png")));
		bookTypePMtMenuItem.setFont(new Font("Microsoft YaHei UI", Font.BOLD, 25));
		bookTypePMtMenuItem.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				BookTypeManageInterFrm bookTypeManageInterFrm=new BookTypeManageInterFrm();
				bookTypeManageInterFrm.setVisible(true);
				table.add(bookTypeManageInterFrm);
				
			}
		});
		bookTypemanageMenu.add(bookTypePMtMenuItem);
		
		JMenu bookManegeMenu = new JMenu("图书管理");
		bookManegeMenu.setIcon(new ImageIcon(BookAdmiMainFrm.class.getResource("/images/bookAdmi/图书管理.png")));
		bookManegeMenu.setFont(new Font("Microsoft YaHei UI", Font.BOLD, 28));
		bookMaintainMenu.add(bookManegeMenu);
		
		JMenuItem bookAddMenuItem = new JMenuItem("图书添加");
		bookAddMenuItem.setIcon(new ImageIcon(BookAdmiMainFrm.class.getResource("/images/bookAdmi/添加.png")));
		bookAddMenuItem.setFont(new Font("Microsoft YaHei UI", Font.BOLD, 25));
		bookAddMenuItem.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				BookAddInterFrm bookAddInterFrm=new BookAddInterFrm();
				bookAddInterFrm.setVisible(true);
				table.add(bookAddInterFrm);
			}
		});
		bookManegeMenu.add(bookAddMenuItem);
		
		JMenuItem bookMtMenuItem = new JMenuItem("图书维护");
		bookMtMenuItem.setIcon(new ImageIcon(BookAdmiMainFrm.class.getResource("/images/bookAdmi/图书维护.png")));
		bookMtMenuItem.setFont(new Font("Microsoft YaHei UI", Font.BOLD, 25));
		bookMtMenuItem.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				BookManageInterFrm bookManageInterFrm=new BookManageInterFrm();
				bookManageInterFrm.setVisible(true);
				table.add(bookManageInterFrm);
				
			}
		});
		bookManegeMenu.add(bookMtMenuItem);
		
		JMenu bookBorrowImfMenu = new JMenu("  图书借阅信息                ");
		bookBorrowImfMenu.setIcon(new ImageIcon(BookAdmiMainFrm.class.getResource("/images/bookAdmi/信息查询 (2).png")));
		bookBorrowImfMenu.setFont(new Font("Microsoft YaHei UI", Font.BOLD, 25));
		menuBar.add(bookBorrowImfMenu);
		
		JMenuItem bookBorrowImfSearchNewMenuItem = new JMenuItem("借阅信息查询");
		bookBorrowImfSearchNewMenuItem.setIcon(new ImageIcon(BookAdmiMainFrm.class.getResource("/images/bookAdmi/借阅查询 .png")));
		bookBorrowImfSearchNewMenuItem.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				AllBorrowImfSearchInterFrm allBorrowImfSearchInterFrm=new AllBorrowImfSearchInterFrm();
				allBorrowImfSearchInterFrm.setVisible(true);
				table.add(allBorrowImfSearchInterFrm);
			}
		});
		bookBorrowImfSearchNewMenuItem.setFont(new Font("Microsoft YaHei UI", Font.BOLD, 28));
		bookBorrowImfMenu.add(bookBorrowImfSearchNewMenuItem);
		
		JMenu bookBorrowMenu = new JMenu("     图书借阅                ");
		bookBorrowMenu.setIcon(new ImageIcon(BookAdmiMainFrm.class.getResource("/images/bookAdmi/借书 (1) (1).png")));
		bookBorrowMenu.setFont(new Font("Microsoft YaHei UI", Font.BOLD, 25));
		menuBar.add(bookBorrowMenu);
		
		JMenuItem bookBorrowMenuItem = new JMenuItem("图书借阅办理");
		bookBorrowMenuItem.setIcon(new ImageIcon(BookAdmiMainFrm.class.getResource("/images/bookAdmi/借阅.png")));
		bookBorrowMenuItem.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				BookBorrowInterFrm bookBorrowInterFrm=new BookBorrowInterFrm();
				bookBorrowInterFrm.setVisible(true);
				table.add(bookBorrowInterFrm);
			}
		});
		bookBorrowMenuItem.setFont(new Font("Microsoft YaHei UI", Font.BOLD, 28));
		bookBorrowMenu.add(bookBorrowMenuItem);
		
		JMenu bookReturnMenu = new JMenu("     图书归还          ");
		bookReturnMenu.setIcon(new ImageIcon(BookAdmiMainFrm.class.getResource("/images/bookAdmi/还书.png")));
		bookReturnMenu.setFont(new Font("Microsoft YaHei UI", Font.BOLD, 25));
		menuBar.add(bookReturnMenu);
		
		JMenuItem bookReturnMenuItem = new JMenuItem("图书归还办理");
		bookReturnMenuItem.setIcon(new ImageIcon(BookAdmiMainFrm.class.getResource("/images/bookAdmi/还书 (1).png")));
		bookReturnMenuItem.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				BookReturnInterFrm bookReturnInterFrm=new BookReturnInterFrm();
				bookReturnInterFrm.setVisible(true);
				table.add(bookReturnInterFrm);
				
				
			}
		});
		bookReturnMenuItem.setFont(new Font("Microsoft YaHei UI", Font.BOLD, 28));
		bookReturnMenu.add(bookReturnMenuItem);
		
		JMenu bookSearchMenu = new JMenu("     图书查询           ");
		bookSearchMenu.setIcon(new ImageIcon(BookAdmiMainFrm.class.getResource("/images/bookAdmi/信息查询 (1).png")));
		bookSearchMenu.setFont(new Font("Microsoft YaHei UI", Font.BOLD, 30));
		menuBar.add(bookSearchMenu);
		
		JMenuItem bookSearchMenuItem = new JMenuItem("图书信息查询");
		bookSearchMenuItem.setIcon(new ImageIcon(BookAdmiMainFrm.class.getResource("/images/bookAdmi/图书查询_intouch.png")));
		bookSearchMenuItem.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				BookSearchInterFrm bookSearchInterFrm=new BookSearchInterFrm();
				bookSearchInterFrm.setVisible(true);
				table.add(bookSearchInterFrm);
			}
		});
		bookSearchMenuItem.setFont(new Font("Microsoft YaHei UI", Font.BOLD, 28));
		bookSearchMenu.add(bookSearchMenuItem);
		
		JMenu logOffMenu = new JMenu("安全退出");
		logOffMenu.setIcon(new ImageIcon(BookAdmiMainFrm.class.getResource("/images/退出登录 (1).png")));
		logOffMenu.setFont(new Font("Microsoft YaHei UI", Font.BOLD, 25));
		menuBar.add(logOffMenu);
		
		JMenuItem logOffMenuItem_1 = new JMenuItem("退出登录");
		logOffMenuItem_1.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				int result=JOptionPane.showConfirmDialog(null, "是否退出登录");
//				System.out.println(result);    可以利用输出进行断点调试
				if(result==0) {
					dispose();
					LogOnFrm1 logOnFrm=new LogOnFrm1();
					logOnFrm.setVisible(true);
				}
			}
		});
		logOffMenuItem_1.setIcon(new ImageIcon(BookAdmiMainFrm.class.getResource("/images/bookAdmi/退出登录.png")));
		logOffMenuItem_1.setFont(new Font("Microsoft YaHei UI", Font.BOLD, 28));
		logOffMenu.add(logOffMenuItem_1);
		
		JMenuItem logOffSystemMenuItem = new JMenuItem("退出系统");
		logOffSystemMenuItem.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				int result=JOptionPane.showConfirmDialog(null, "是否退出系统");
//				System.out.println(result);    可以利用输出进行断点调试
				if(result==0) {
					dispose();
					
				}
			}
		});
		logOffSystemMenuItem.setIcon(new ImageIcon(BookAdmiMainFrm.class.getResource("/images/bookAdmi/退出登录.png")));
		logOffSystemMenuItem.setFont(new Font("Microsoft YaHei UI", Font.BOLD, 28));
		logOffMenu.add(logOffSystemMenuItem);
		contentPane = new JPanel();
		contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
		setContentPane(contentPane);
		contentPane.setLayout(new BorderLayout(0, 0));
		table.setBackground(new Color(255, 192, 203));
		
		
		contentPane.add(table, BorderLayout.CENTER);
		
		
//		ImageIcon backIcon=new ImageIcon(getClass().getResource("/images/bookAdmi/管理员背景图.jpeg"));
//		 //final JLabel backLabel=new JLabel(backIcon); // 创建背景标签
//		 JLabel backLabel=new JLabel(backIcon); // 创建背景标签
//		
//		backLabel.setSize(backIcon.getIconWidth(), backIcon.getIconHeight());
//		
//		 backLabel.setLocation(0, 0);
//		 // 设置标签定位
//		 //contentPane.add(backLabel); // 添加标签到窗体
//		 table.add(backLabel);
//		setResizable(true);//可以改变窗体大小
		
		
		
		//设置JFrame最大化
		this.setExtendedState(JFrame.MAXIMIZED_BOTH);
		
		
	}
}
